/Users/zhangjin/Opt/elasticsearch-migration/esm -s http://10.150.24.13:9200 -d http://10.160.13.143:9200 -x .eagleeye-setting



#迁移setting
curl -XPOST http://10.160.13.143:9200/_reindex -d '{
  "source": {
    "remote": {
      "host": "http://10.150.24.13:9200"
    },
    "index": ".eagleeye-setting",
    "query": {
      "match": {
        "_type": "setting"
      }
    }
  },
  "dest": {
    "index": ".eagleeye-setting"
  }
}
'
#迁移user
curl -XPOST http://10.160.13.143:9200/_reindex -d '{
  "source": {
    "remote": {
      "host": "http://10.150.24.13:9200"
    },
    "index": ".eagleeye-setting",
    "query": {
      "match": {
        "_type": "user"
      }
    }
  },
  "dest": {
    "index": ".eagleeye-setting-user"
  }
}
'
#迁移platform
curl -XPOST http://10.160.13.143:9200/_reindex -d '{
  "source": {
    "remote": {
      "host": "http://10.150.24.13:9200"
    },
    "index": ".eagleeye-setting",
    "query": {
      "match": {
        "_type": "platform"
      }
    }
  },
  "dest": {
    "index": ".eagleeye-setting-platform"
  }
}
'
#迁移alert
curl -XPOST http://10.160.13.143:9200/_reindex -d '{
  "source": {
    "remote": {
      "host": "http://10.150.24.13:9200"
    },
    "index": ".eagleeye-setting",
    "query": {
      "match": {
        "_type": "alert"
      }
    }
  },
  "dest": {
    "index": ".eagleeye-setting-alert"
  }
}
'


#-----------------------------------#
cd /Users/zhangjin/Opt/elasticsearch-dump-4.2.0/bin/

#导出
./elasticdump \
  --input=http://10.160.13.143:9200/.eagleeye-setting \
  --output=eagleeye-setting.json \
  --type=data

./elasticdump \
  --input=http://10.160.13.143:9200/.eagleeye-setting-platform \
  --output=eagleeye-setting-platform.json \
  --type=data


./elasticdump \
  --input=http://10.160.13.143:9200/.eagleeye-setting-user \
  --output=eagleeye-setting-user.json \
  --type=data

/Users/zhangjin/Opt/elasticsearch-dump-4.2.0/bin/elasticdump \
  --input=http://10.160.13.143:9200/.eagleeye-setting-alert \
  --output=eagleeye-setting-alert.json \
  --type=data

#导入
./elasticdump \
  --input=./eagleeye-setting.json \
  --output=http://10.160.13.144:9200/.eagleeye-setting \
  --type=data

./elasticdump \
  --input=./eagleeye-setting-user.json \
  --output=http://10.160.13.144:9200/.eagleeye-setting-user \
  --type=data

./elasticdump \
  --input=./eagleeye-setting-platform.json \
  --output=http://10.160.13.144:9200/.eagleeye-setting-platform \
  --type=data

./elasticdump \
  --input=./eagleeye-setting-alert.json \
  --output=http://10.160.13.144:9200/.eagleeye-setting-alert \
  --type=data

#只导入用户系统设置
curl -H "Content-Type: application/json" -XPUT "10.0.1.13:9200/.eagleeye-setting/setting/setting" -d '{"envList":["dev","test","pre"],"resultList":["OK","ERROR"],"rpcTypeList":["ice","ws","http","db","redis","mq","task","dubbo"],"userInfoTypeList":["phone","userId","customerId","realName"]}'
curl -H "Content-Type: application/json" -XPUT "10.0.1.13:9200/.eagleeye-setting-user/user/admin" -d '{"password":"1qaz@WSX","platformList":["all"],"userName":"admin"}'
curl -H "Content-Type: application/json" -XPUT "10.0.1.13:9200/.eagleeye-setting/alert/csc-rule-01" -d '{"describe":"恒昌财富每2分钟异常报警","emails":"caifu-dev@credithc.com","enable":true,"env":"product","jobPeriodSeconds":120,"platformName":"csc","queryString":"result:\"ERROR \"","ruleId":"rule-csc-01","statSecondsAgo":120,"triggerCount":1}'
